<template>
  <div class="user-info-card">
    <div class="card-header">
      <div class="user-avatar-section">
        <el-avatar :size="60" class="user-avatar">
          <el-icon><User /></el-icon>
        </el-avatar>
        <div class="user-basic-info">
          <h3 class="user-name">{{ userInfo?.UserName || '用户' }}</h3>
          <p class="user-id">ID: {{ userInfo?.UserId || 'N/A' }}</p>
          <el-tag :type="userInfo?.Status ? 'success' : 'danger'" size="small">
            {{ userInfo?.Status ? '在线' : '离线' }}
          </el-tag>
        </div>
      </div>
    </div>

    <div class="card-content">
      <div class="info-section">
        <h4 class="section-title">
          <el-icon><User /></el-icon>
          角色信息
        </h4>
        <div class="roles-list">
          <el-tag 
            v-for="role in userInfo?.Roles || []" 
            :key="role.RoleId"
            type="primary"
            class="role-tag"
          >
            {{ role.RoleName }}
          </el-tag>
          <el-empty v-if="!userInfo?.Roles?.length" description="暂无角色" :image-size="60" />
        </div>
      </div>

      <div class="info-section">
        <h4 class="section-title">
          <el-icon><Key /></el-icon>
          权限信息
        </h4>
        <div class="permissions-list">
          <el-tag 
            v-for="permission in userInfo?.Permissions || []" 
            :key="permission.PermissionId"
            type="success"
            class="permission-tag"
          >
            {{ permission.PermissionName }}
          </el-tag>
          <el-empty v-if="!userInfo?.Permissions?.length" description="暂无权限" :image-size="60" />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { User, Key } from '@element-plus/icons-vue'

interface Role {
  RoleId: number
  RoleName: string
}

interface Permission {
  PermissionId: number
  PermissionName: string
  Component: string
}

interface UserInfo {
  UserId: number
  UserName: string
  Status: boolean
  Roles: Role[]
  Permissions: Permission[]
}

defineProps<{
  userInfo?: UserInfo
}>()
</script>

<style scoped>
.user-info-card {
  width: 100%;
  max-width: 1200px;
  min-width: 320px;
  border-radius: 24px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.10);
  background: #fff;
  margin: 0 auto;
  padding: 0 24px 32px 24px;
}

.card-header {
  background: linear-gradient(135deg, #409EFF 0%, #67C23A 100%);
  padding: 32px 40px 24px 40px;
  color: white;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
}

.user-avatar-section {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-avatar {
  background: rgba(255, 255, 255, 0.2);
  border: 3px solid rgba(255, 255, 255, 0.3);
}

.user-basic-info {
  flex: 1;
}

.user-name {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: white;
}

.user-id {
  font-size: 14px;
  margin: 0 0 12px 0;
  opacity: 0.8;
  color: white;
}

.card-content {
  padding: 24px;
}

.info-section {
  margin-bottom: 24px;
}

.info-section:last-child {
  margin-bottom: 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 2px solid #f0f0f0;
}

.section-title .el-icon {
  color: #667eea;
}

.roles-list,
.permissions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
  align-items: center;
}

.role-tag,
.permission-tag {
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.role-tag:hover,
.permission-tag:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.role-tag {
  background: linear-gradient(135deg, #409EFF 0%, #67C23A 100%);
  color: #fff;
}

.permission-tag {
  background: linear-gradient(135deg, #67C23A 0%, #409EFF 100%);
  color: #fff;
}

.el-tag[type='success'] {
  background: #67C23A !important;
  color: #fff !important;
  border: none !important;
}

/* 响应式设计 */
@media (max-width: 900px) {
  .user-info-card {
    max-width: 98vw;
    padding: 0 8px 16px 8px;
  }
}
</style> 